//#include <QGuiApplication>
//#include <QQmlApplicationEngine>

//int main(int argc, char *argv[])
//{
//    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

//    QGuiApplication app(argc, argv);

//    QQmlApplicationEngine engine;
//    const QUrl url(QStringLiteral("qrc:/main.qml"));
//    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
//                     &app, [url](QObject *obj, const QUrl &objUrl) {
//        if (!obj && url == objUrl)
//            QCoreApplication::exit(-1);
//    }, Qt::QueuedConnection);
//    engine.load(url);

//    return app.exec();
//}


#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>

#include "backend.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    BackEnd backend;

    QQuickView view;
    view.engine()->rootContext()->setContextProperty("mybackend", &backend);
    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.show();

//    QQmlApplicationEngine engine;
//    //在加载对应的URL之前, 设置上下文属性
//    engine.rootContext()->setContextProperty("mybackend", &backend);
//    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));


    return app.exec();
}
